package checkers.client.run;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import checkers.common.logic.classes.CheckersPosition;

public class CheckersButton extends JButton {

	private static final long serialVersionUID = 1;
	private int x, y, type;
	private int playerMotionVariant = -1;
	
	public CheckersButton(int x, int y) {
		this.x = x;
		this.y = y;
		this.setFocusable(false);
		this.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				buttonPressed();
			}
		});
	}
	
	private void buttonPressed() {
		
	}
	
	public void set(int type) {
		this.type = type;
		switch (type) {
			case CheckersPosition.emptyCell:
				this.setBackground(Color.yellow); break;
			case CheckersPosition.whiteChecker:
				this.setBackground(Color.white); break;
			case CheckersPosition.blackChecker:
				this.setBackground(Color.black); break;
			case CheckersPosition.whiteKing:
				this.setBackground(Color.blue); break;
			case CheckersPosition.blackKing:
				this.setBackground(Color.green); break;
		}
	}
	
	public void setActivity(int v) {
		this.playerMotionVariant = v;
		if (v>=0) {
			this.setBackground(new Color(100, 200, 100));
		} else set(type);
	}

}
